/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package sheep.JUNG.utils;

import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.geom.Rectangle2D;

import edu.uci.ics.jung.graph.Vertex;
import edu.uci.ics.jung.visualization.PluggableRenderer;

//////////////////////////////////////////////////////////////////////////////////////

/**
 * @author Nicolas Baumann
 * @author Alexandre Dos Santos Coelho
 * @author Mathieu Richard
 *
 */
public class OurPluggableRenderer extends PluggableRenderer{

//////////////////////////////////////////////////////////////////////////////////////

	/* (non-Javadoc)
	 * @see edu.uci.ics.jung.visualization.PluggableRenderer#labelVertex(java.awt.Graphics, edu.uci.ics.jung.graph.Vertex, java.lang.String, int, int)
	 */
	@SuppressWarnings("deprecation")
        @Override
	protected void labelVertex(Graphics g, Vertex v, String label, int x, int y) {
	    Component component = prepareRenderer(graphLabelRenderer, label, isPicked(v), v);

	    Dimension d = component.getPreferredSize();    
	    int h_offset;
	    int v_offset;
	    //if (centerVertexLabel){
	      //  h_offset = -d.width / 2;
	        //v_offset = -d.height / 2;

	    //} else{
	        h_offset = 20;
	        v_offset = d.height / 2;
	    //}

//	    component = prepareRenderer(graphLabelRenderer, label, isPicked(v), v);
//	    rendererPane.paintComponent(g, component, screenDevice, x+h_offset, y+v_offset,
//	            d.width, d.height, true);
	    
            String[] labelsTab = label.split(";");
            
            for(int i = 0; i < labelsTab.length; i++)
            {
              component = prepareRenderer(graphLabelRenderer, labelsTab[i], isPicked(v), v);
              rendererPane.paintComponent(g, component, screenDevice, x+h_offset, y+(2*i*v_offset+5),
	            d.width, d.height, true);
            }
	/*    label= label.substring(label.indexOf(',')+1);
	    
	    component = prepareRenderer(graphLabelRenderer, label.substring(0,label.indexOf(',')), isPicked(v), v);
	    rendererPane.paintComponent(g, component, screenDevice, x+h_offset, y+3*v_offset,
	            d.width, d.height, true);
	    
	    label= label.substring(label.indexOf(',')+1);
	    
	    component = prepareRenderer(graphLabelRenderer, label.substring(0,label.indexOf(',')), isPicked(v), v);
	    rendererPane.paintComponent(g, component, screenDevice, x+h_offset, y+5*v_offset,
	            d.width, d.height, true);	    
	    
	    label= label.substring(label.indexOf(',')+1);
	    
	    component = prepareRenderer(graphLabelRenderer, label.substring(0,label.indexOf(',')), isPicked(v), v);
	    
	    rendererPane.paintComponent(g, component, screenDevice, x+h_offset, y+7*v_offset,
	            d.width, d.height, true);
	    
	    
	    label= label.substring(label.indexOf(',')+1);
	    
	    component = prepareRenderer(graphLabelRenderer, label, isPicked(v), v);
	    rendererPane.paintComponent(g, component, screenDevice, x+h_offset, y+9*v_offset,
	            d.width, d.height, true);	   
         */ 
            
	}
	
//////////////////////////////////////////////////////////////////////////////////////
	
}
